/*
 * heap_sort.c
 *
 *  Created on: Mar 25, 2014
 *      Author: jack
 */
#include<stdio.h>

void shell_sort(int arr[],int len) {
    int setp,j,k;
    for(setp = len/2;setp>=1; setp=setp/2) {
        for(j=setp;j<len;j++) {
            int tmp = arr[j];
            for(k=j-setp;k>=0;k=k-setp) {
                if(tmp<arr[k]) {
                    arr[k+setp]=arr[k];
                }else {
                    break;
                }
            }
            arr[k+setp]=tmp;
        }
//        printf("Step = %d\n",setp);
//        print_array(arr,len);
    }
}
